function addformreservationregister()
{

$("#addform").append('<div id="feature'+rowdiv+'" class="itPlg addHshPlug featureclass">'+dataform['reservationregister']+"</div>");
var rownow=rowdiv;
   $('#feature'+rownow+' .deleterowbutton').click(function(){
   
    $('#feature'+rownow).remove();
    
   });
rowdiv++;

}

function checkuserconfirmregister(idresv,productid)
{
var statusset=1;
if($("#checkuser-"+idresv).is(':checked'))
{

     statusset=2;

}else
{
    statusset=1;

}
var parem=new Array();
parem[0]=idresv;
parem[1]=productid;
parem[2]=statusset;

loaddata();
$.get(serviceinfo+'getmedthodplugin', { classset:'reservationregister',medthodset:'confirmreservation',parem:parem }, function(data) { 
loadclosedata();
if(data.error.response)
{
if(data.error.error[0].code==5)
{
$('.ovlPopLd').hide();
$('.wrpPopSU').fadeIn();

}else
{
boxmsgdata(data.error.error[0].msg);

}


}else
{

   if(statusset==1)
   {
   
   $(".wrpWaitRgt .lstWait").append($("#liuser-"+idresv));
   }else
   {
   $(".wrpCfmRgt .lstCfm").append($("#liuser-"+idresv));
   
   }
   countelementbox();



}
});


}

function deleteuserconfirmregister(idresv,productid)
{

boxconfirmmsgdata('Delete ?','deleteuserconfirmsetregister',idresv+','+productid);



}

function exportuserreservationlistregister(productid,status)
{
var statusset=0;
if(status)
{
statusset=status;
}

location.href=serviceinfo+'getmedthodplugin?classset=reservationregister&medthodset=exportuser&parem[]='+productid+'&parem[]='+statusset+'&nojson=1';




}

function deleteuserconfirmsetregister(idresv,productid)
{



var parem=new Array();
parem[0]=idresv;
parem[1]=productid;


loaddata();
$.get(serviceinfo+'getmedthodplugin', { classset:'reservationregister',medthodset:'deleteuserreservation',parem:parem }, function(data) { 
loadclosedata();
if(data.error.response)
{
if(data.error.error[0].code==5)
{
$('.ovlPopLd').hide();
$('.wrpPopSU').fadeIn();

}else
{
boxmsgdata(data.error.error[0].msg);

}


}else
{

   $("#liuser-"+idresv).remove();
   countelementbox();



}
});


}

function countelementboxregister()
{
;
$(".countwaitinglist").html($(".wrpWaitRgt .lstWait li").length);
$(".countconfirmlist").html($(".wrpCfmRgt .lstCfm li").length);

}

function resendemailregister(productid,resid)
{




}

function getformreservationregister_bk(dataplugin)
{

 
var statusnumberid='';
if(useridinfo!='0')
{
statusnumberid='Your Canonlife ID '+useridinfo;

}

var code = '<div class="ldIt wrpFrmLd clBg4" id="reserveform-'+dataplugin['resid']+'">\n';
code += '<div class="wrpHdInfoGen mgBtm10">\n';
code += '<h2 class="clTxt2 fs04 boldGen">Reservation '+statusnumberid+'</h2>\n';
code += '</div>\n';
code += '<div class="wrpRsv bdBtm clBd2">\n';
code += '<div class="rsvBtnJoin clBgSp2" onclick="savereservedataregister('+dataplugin.productid+','+dataplugin['resid']+')">\n';
code += '<span class="clTxtW fs11">JOIN THIS !!!</span>\n';
code += '</div>\n';
code += '<div class="cpltRsv fs04 clTxt2">To complete reservation, you must confirmation via your email address.</div>\n';
code += '</div>\n';


var str1="";
var krow1=0;
var str2="";
var krow2=0;
var checkuserre="";

//if(dataplugin['checkmy']||roleidinfo==3)

if(useridinfo!='0')
{
if(dataplugin['userlist'].length)
{
$.each(dataplugin['userlist'], function(key, value) {

checkuserre='';
if(value['status']=='2')
{
checkuserre=' checked="checked" ';
}
if((dataplugin['checkmy']||roleidinfo==3)||dataplugin.showlist=='1'  )
{
var code1 = '<li class="clearfix" id="liuser-'+value['resvid']+'">\n';
code1 += '<div class="rgtName">\n';
if(dataplugin['checkmy']||roleidinfo==3)
{
code1 += '<input id="checkuser-'+value['resvid']+'"  '+checkuserre+' type="checkbox" onclick="checkuserconfirmregister('+value['resvid']+','+dataplugin.productid+')" >\n';
}
code1 += '<a href="'+baseinfo+'/'+value['username']+'" target="_blank"><img width="24" height="24" alt="img" src="'+value['userssimg']['newpath']+'" class="genImgUser">\n';
code1 += '<span class="cutTxt">'+value['displayname']+'</span></a>\n';
code1 += '</div>\n';
if(dataplugin['checkmy']||roleidinfo==3)
{
code1 += '<span class="rgtInfo rgsDelRsv" onclick="deleteuserconfirmregister('+value['resvid']+','+dataplugin.productid+')" >\n';
code1 += '<em class="ico icoDelRsv"></em>\n';
code1 += '</span>\n';
code1 += '<span class="rgtInfo rgtInfoRsv" onclick="openaddreservationregister(\''+value['displayname']+'\',\''+value['email']+'\',\''+value['phone']+'\')" >\n';
code1 += '<em class="ico icoInfoRsv"></em>\n';
code1 += '</span>\n';
}
code1 += '</li>';
}else
{
code1='';

}
if(value['status']=='1')
{
str1+=code1;
krow1++;

}else
{
str2+=code1;
krow2++;

}



});


}


code += '<div class="wrprRgtCfm clearfix">\n';
code += '<div class="wrpWaitRgt clBd2 bdR">\n';
code += '<div class="wrpHdWaitRgt clearfix">\n';
code += '<h2 class="boldGen fs04 clTxt2">Waiting Status (<span class="countwaitinglist">'+krow1+'</span>/'+dataplugin.reserve+')</h2>\n';
if(dataplugin['checkmy']||roleidinfo==3)
{
code += '<input type="submit" class="btnEPRsv clBgBt1" onclick="exportuserreservationlistregister('+dataplugin['productid']+',1)" value="">\n';
code += '<input type="submit" class="btnMail clBgBt1" onclick="emailuserreservationlistregister('+dataplugin['productid']+',1)" value="">\n';
}
code += '</div>\n';
 code+= '<ul class="lstWait">\n';

code+=str1;

code += '</ul>\n';
code += '</div>\n';
code += '<div class="wrpCfmRgt">\n';
code += '<div class="wrpHdWaitRgt clearfix">\n';
code += '<h2 class="boldGen fs04 clTxt2">Confirmation Status (<span class="countconfirmlist">'+krow2+'</span>/'+dataplugin.seat+')</h2>\n';
if(dataplugin['checkmy']||roleidinfo==3)
{
code += '<input type="submit" class="btnEPRsv clBgBt1" onclick="exportuserreservationlistregister('+dataplugin['productid']+',2)" value="">\n';
code += '<input type="submit" class="btnMail clBgBt1" onclick="emailuserreservationlistregister('+dataplugin['productid']+',2)" value="">\n';
}
code += '</div>\n';
code += '<ul class="lstCfm">\n';

code+=str2;

code += '</ul>\n';
code += '</div>\n';
code += '</div>';



}
code+='</div><div class="ldIt wrpFrmLd wrpRgtFrmPlgLd clBg4" id="registerform-'+dataplugin['resid']+'" style="display:none"></div>';


return code;






}
function getformreservationregister(dataplugin)
{
var  arraydata=dataplugin;
  
var code  = '<div class="ldIt wrpFrmLd clBg4" id="reserveform-'+arraydata['resid']+'">'+"\n";

code += '<div class="wrpHdInfoGen mgBtm10">'+"\n";
code += '<h2 class="clTxt2 fs04 boldGen">Reservation </h2>'+"\n";
code += '</div>'+"\n";




code += '<div class="wrpRsv bdBtm clBd2 registerbtndiv" id="landingregister-'+arraydata['resid']+'">'+"\n";

var krow1=0;
var krow2=0;
if(arraydata['userlistwaiting'].length)
{


var resvid=0;
$.each(arraydata['userlistwaiting'], function(key, valueuserlist) {

resvid=valueuserlist['resvid'];
if(valueuserlist['status']==1)
{
krow1++;
}else
{
krow2++;
}

});

}




var fully=0;
if((parseInt(arraydata['countconfirm'],10)>=parseInt(arraydata['seat'],10) )&&parseInt(arraydata['unseat'],10)==0)
{
fully=1;

}
if(fully==1&&arraydata['checkhave']<1)
{
code +='<div class="rsvThankJoin"><span class="clTxt1 fs11">Fully Reserved</span></div>';
}else
{
if(arraydata['checkhave']==0)
{


code +='<div class="rsvBtnJoin clBgSp2" onclick="savereservedataregister('+arraydata['productid']+','+arraydata['resid']+')">'+"\n";
code += '<span class="clTxtW fs11">JOIN THIS !!!</span>'+"\n";
code += '</div>'+"\n";

}
else if(arraydata['checkhave']==1)
{
code += '<div class="rsvThankJoin"><span class="clTxt1 fs11">Thank You For Joining Us</span></div>'+"\n";

}
else
{
 code +='<div class="rsvThankJoin"><span class="clTxt1 fs11">Successful Confirmation</span><span class="clTxt1 fs11">Your Canon ID : '+useridinfo+' </span></div>'+"\n";

}
}
if(fully==1&&arraydata['checkhave']<1)
{
code +='<div class="cpltRsv fs04 clTxt2"><span>Do not be sad. In the future we also have activities for you to enjoy.</span></div>';
}else
{
if(arraydata['checkhave']==2)
{
code +='<div class="cpltRsv fs04 clTxt2"><span>Use your \'Canon ID\' and \'Order Number\' to contact in front of event.</span></div>';

}
else if(arraydata['checkhave']==1)
{

//code += '<div class="cpltRsv fs04 clTxt2">To complete reservation, you must confirmation via your email address.</div>'+"\n";


code +='<div class="cpltRsv fs04 clTxt2"><span>To complete reservation, you must confirmation via your email address.</span><span>If you do not receiving email from us, please check your Junk Email folder</span><span>or <a href="javascript:savereservedataregister('+arraydata['productid']+','+arraydata['resid']+')">click here to re-send email.</a></span></div>';
}
}

code += '</div>'+"\n";



if(useridinfo)
{



code += '<div class="wrprRsvTtl">'+"\n";
code += '<div class="wrpInRsvTtl clearfix">'+"\n";
code += '<div class="wrpRsvTtl wtTtlRsv clBg5 bdFull clBd2">'+"\n";
code += '<div class="hdRsvTtl">'+"\n";
code += '<span class="boldGen fs05 clTxt1">Total Waiting</span>'+"\n";
code += '</div>'+"\n";
code += '<div class="bdRsvTtl">'+"\n";
code += '<span class="fs07 clTxt1">'+arraydata['countwaiting']+'</span>'+"\n";
code += '</div>'+"\n";
code += '</div>'+"\n";
code += '<div class="wrpRsvTtl cfTtlRsv clBg5 bdFull clBd2">'+"\n";
code += '<div class="hdRsvTtl">'+"\n";
code += '<span class="boldGen fs05 clTxt1">Total Confirmation</span>'+"\n";
code += '</div>'+"\n";
code += '<div class="bdRsvTtl">'+"\n";
code += '<span class="fs07 clTxt1">'+arraydata['countconfirm']+'</span>'+"\n";
code += '</div>'+"\n";
code += '</div>'+"\n";

if(arraydata['checkhave']==2)
{
code += '<div class="wrpRsvTtl ordTtlRsv clBg5 bdFull clBd2">'+"\n";

code += '<div class="hdRsvTtl">'+"\n";
code += '<span class="boldGen fs05 clTxt1">Reservation Number</span>'+"\n";
code += '</div>'+"\n";

code += '<div class="bdRsvTtl">'+"\n";
code += '<span class="fs07 clTxt1">'+arraydata['resvid']+'</span>'+"\n";
code += '</div>'+"\n";

code += '</div>'+"\n";
}

code += '</div>'+"\n";
code += '</div>';


if(useridinfo&&arraydata['checkmy']||roleidinfo==3||arraydata['showlist']=='1')
{



var str1="";
krow1=0;
var str2="";
krow2=0;
if(arraydata['userlistwaiting'].length)
{


$.each(arraydata['userlistwaiting'], function(key, valueuserlist) {


if((arraydata['checkmy']||roleidinfo==3)||arraydata['showlist']=='1')
{

var code1= '<li class="clearfix" id="liuser-'+valueuserlist['resvid']+'">'+"\n";
code1 += '<div class="rgtName">'+"\n";

var check='';
if(valueuserlist['status']==2)
{
var check=' checked="checked" ';
}
if(arraydata['checkmy']||roleidinfo==3)
{
code1 += '<input id="checkuser-'+valueuserlist['resvid']+'" type="checkbox" '+check+' onclick="checkuserconfirmregister('+valueuserlist['resvid']+','+arraydata['productid']+')">'+"\n";
}


code1 += '<a href="'+baseinfo+'/'+valueuserlist['username']+'" target="_blank"><img width="24" height="24" alt="img" src="'+valueuserlist['userssimg']['newpath']+'" class="genImgUser">'+"\n";
code1 += '<span class="cutTxt">'+valueuserlist['displayname']+'</span></a>'+"\n";
code1 += '</div>'+"\n";
if(arraydata['checkmy']||roleidinfo==3)
{
code1 += '<span class="rgtInfo rgsDelRsv" onclick="deleteuserconfirmregister('+valueuserlist['resvid']+','+arraydata['productid']+')" >'+"\n";
code1 += '<em class="ico icoDelRsv"></em>'+"\n";
code1 += '</span>'+"\n";
code1 += '<span class="rgtInfo rgtInfoRsv" onclick="openaddreservationregister(\''+valueuserlist['displayname']+'\',\''+valueuserlist['email']+'\',\''+valueuserlist['phone']+'\')">'+"\n";
code1 += '<em class="ico icoInfoRsv"></em>'+"\n";
code1 += '</span>'+"\n";
}
code1 += '</li>'+"\n";

}else
{
var code1='';

}





if(valueuserlist['status']==1)
{
str1+=code1;
krow1++;

}else
{
str2+=code1;
krow2++;

}





} );
}


if(arraydata['userlistconfirm'].length)
{


$.each(arraydata['userlistconfirm'], function(key, valueuserlist) {


if((arraydata['checkmy']||roleidinfo==3)||arraydata['showlist']=='1')
{

var code1= '<li class="clearfix" id="liuser-'+valueuserlist['resvid']+'">'+"\n";
code1 += '<div class="rgtName">'+"\n";

var check='';
if(valueuserlist['status']==2)
{
var check=' checked="checked" ';
}
if(arraydata['checkmy']||roleidinfo==3)
{
code1 += '<input id="checkuser-'+valueuserlist['resvid']+'" type="checkbox" '+check+' onclick="checkuserconfirmregister('+valueuserlist['resvid']+','+arraydata['productid']+')">'+"\n";
}


code1 += '<a href="'+baseinfo+'/'+valueuserlist['username']+'" target="_blank"><img width="24" height="24" alt="img" src="'+valueuserlist['userssimg']['newpath']+'" class="genImgUser">'+"\n";
code1 += '<span class="cutTxt">'+valueuserlist['displayname']+'</span></a>'+"\n";
code1 += '</div>'+"\n";
if(arraydata['checkmy']||roleidinfo==3)
{
code1 += '<span class="rgtInfo rgsDelRsv" onclick="deleteuserconfirmregister('+valueuserlist['resvid']+','+arraydata['productid']+')" >'+"\n";
code1 += '<em class="ico icoDelRsv"></em>'+"\n";
code1 += '</span>'+"\n";
code1 += '<span class="rgtInfo rgtInfoRsv" onclick="openaddreservationregister(\''+valueuserlist['displayname']+'\',\''+valueuserlist['email']+'\',\''+valueuserlist['phone']+'\')">'+"\n";
code1 += '<em class="ico icoInfoRsv"></em>'+"\n";
code1 += '</span>'+"\n";
}
code1 += '</li>'+"\n";

}else
{
var code1='';

}





if(valueuserlist['status']==1)
{
str1+=code1;
krow1++;

}else
{
str2+=code1;
krow2++;

}





} );
}


checkmypost=arraydata['checkmy'];
showlist=arraydata['showlist'];


code += '<div class="wrprRgtCfm clearfix">'+"\n";
code += '<div class="wrpWaitRgt clBd2 bdR">'+"\n";
code += '<div class="wrpHdWaitRgt clearfix">'+"\n";
code += '<h2 class="boldGen fs04 clTxt2">Waiting Status (<span class="countwaitinglist">'+arraydata['countwaiting']+'</span>/'+arraydata['reserve']+')</h2>'+"\n";
if(arraydata['checkmy']||roleidinfo==3)
{
code += '<input type="submit" class="btnEPRsv clBgBt1" onclick="exportuserreservationlistregister('+arraydata['productid']+',1)" value="">'+"\n";
code += '<input type="submit" class="btnMail clBgBt1" onclick="emailuserreservationlistregister('+arraydata['productid']+',1)" value="">'+"\n";
}

code += '</div>'+"\n";
code +='<div class="srchRgt"><div class="wrpSrchBox"><input type="text" class="srchBox clBg4 fs01 clTxt3 searchwaiting" placeholder="Search"><div class="btnIco srchGen" onclick="searchreservationdata('+arraydata['productid']+',1)"><span class="ico icoSrchGen"></span></div></div></div>';
code += '<ul class="lstWait">'+"\n";


code+=str1;


code += '</ul>'+"\n";
code +='<div class="pagewaiting"></div>'+"\n";

code += '</div>'+"\n";

code += '<div class="wrpCfmRgt">'+"\n";
code += '<div class="wrpHdWaitRgt clearfix">'+"\n";
code += '<h2 class="boldGen fs04 clTxt2">Confirmation Status (<span class="countconfirmlist">'+arraydata['countconfirm']+'</span>/'+arraydata['seat']+')</h2>'+"\n";
if(arraydata['checkmy']||roleidinfo==3)
{
code += '<input type="submit" class="btnEPRsv clBgBt1" onclick="exportuserreservationlistregister('+arraydata['productid']+',2)" value="">'+"\n";
code += '<input type="submit" class="btnMail clBgBt1" onclick="emailuserreservationlistregister('+arraydata['productid']+',2)" value="">'+"\n";
}

code += '</div>'+"\n";
code +='<div class="srchRgt"><div class="wrpSrchBox"><input type="text" class="srchBox clBg4 fs01 clTxt3 searchconfirm" placeholder="Search"><div class="btnIco srchGen" onclick="searchreservationdata('+arraydata['productid']+',2)"><span class="ico icoSrchGen"></span></div></div></div>';
code += '<ul class="lstCfm">'+"\n";

code+=str2;



code += '</ul>'+"\n";
code +='<div class="pagecomfirm"></div>'+"\n";
code += '</div>'+"\n";
code += '</div>'+"\n";




}


}




code += '</div><div class="ldIt wrpFrmLd wrpRgtFrmPlgLd clBg4" id="registerform-'+arraydata['resid']+'" style="display:none"></div><div style="display:none" ><div class="productidset">'+arraydata['productid']+'</div><div class="countwaitinglistset">'+arraydata['countwaiting']+'</div><div class="countconfirmlistset">'+arraydata['countconfirm']+'</div></div>';




  return code; 


  
  
  }
  function initreservationregis()
  {
  if($('#main-middle .countwaitinglistset').html())
  {
  if(showlist=='1'||checkmypost||roleidinfo==3)
  {
  getpageuserlist("#main-middle .pagewaiting",parseInt($('#main-middle .countwaitinglistset').html(),10),10,parseInt($('#main-middle .productidset').html(),10),1);
  
  getpageuserlist("#main-middle .pagecomfirm",parseInt($('#main-middle .countconfirmlistset').html(),10),10,parseInt($('#main-middle .productidset').html(),10),1);
  }
  }
  
  }
var firstemailuser=1;
function emailuserreservationlistregister(productid,status)
{
$('.wrpPopSendMail').fadeIn();
if(firstemailuser)
{
firstemailuser=0;
$('#frombroadcast2').submit(function() {
if($('#txtbroadcast2').val())
{
var parem=new Array();
parem[0]=productid;
parem[1]=status;
parem[2]=$('#txtbroadcast2').val();
parem[3]=$('#titleemail').val();

loaddata();
$.post(serviceinfo+'postmedthodplugin', { classset:'reservationregister',medthodset:'emailreseruser',parem:parem }, function(data) { 

loadclosedata();
if(data.error.response)
{

boxmsgdata(data.error.error);

//alertboxtext(data.error.error,$("#validateerror-login"));

}else
{
boxmsgdata('Success');
//$('#txtbroadcast2').val('');
//location.href=baseinfo;


}


});


}
return false;
});
}

}

function openaddreservationregister(userset,email,tel)
{

var code = '<div class="wrpMiniPop clBgBt1">\n';
code += '<div class="miniPop">\n';
code += '<span class="txtMiniPop txtSUMiniPop fs03 clTxtW">'+userset+'<br></span>\n';
code += '<span class="txtMiniPop txtSUMiniPop fs03 clTxtW">Tel: <em>'+tel+'</em><br></span>\n';
code += '<span class="txtMiniPop txtSUMiniPop fs03 clTxtW">Email: <em>'+email+'</em></span>\n';
code += '<div class="wrpBtnMiniPop">\n';
code += '<span class="btnIco btnMiniPop btnOK clTxtW fs03" onclick="$(\'.wrprMiniPop.wrpPopMiniRgt\').fadeOut()">OK</span>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>';

$(".wrprMiniPop.wrpPopMiniRgt").html(code);
$(".wrprMiniPop.wrpPopMiniRgt").fadeIn();


}
function loginuserreservation(productid,resid)
{
var checkerror=new Array();
var rowerror=0;
var datasend={};

if($('#registerform-'+resid+' input[name="username_login"]').val()=="")
{
boxmsgdata('Please Input Username');
$('#registerform-'+resid+' input[name="username_login"]').focus();
return false;


}else
{
 if(validateEmail($('#registerform-'+resid+' input[name="username_login"]').val()))
    {
    datasend['email']=$('#registerform-'+resid+' input[name="username_login"]').val();
    
    }else
    {
    datasend['username']=$('#registerform-'+resid+' input[name="username_login"]').val();
    
    }

}


if($('#registerform-'+resid+' input[name="password_login"]').val()=="")
{

boxmsgdata('Please Input Password');
$('#registerform-'+resid+' input[name="password_login"]').focus();



}else
{

datasend['password']=$('#registerform-'+resid+' input[name="password_login"]').val();

loaddata();
$.post(serviceinfo+"login",datasend,
function(data){
loadclosedata();
if(data.error.response)
{
//console.log(data.error.error[0]);
boxmsgdata(data.error.error[0].msg);

}else
{

savereservedataregister(productid,resid);


}

});


}


}

function signupuserreservation(productid,resid)

{
var checkerror=new Array();
var rowerror=0;
var datasend={};

if($('#registerform-'+resid+' input[name="username_signup"]').val()=="")
{
boxmsgdata('Please Input Username');
$('#registerform-'+resid+' input[name="username_signup"]').focus();
return false;


}
else
{

    datasend['username']=$('#registerform-'+resid+' input[name="username_signup"]').val();
    
    

}


if($('#registerform-'+resid+' input[name="email_signup"]').val()=="")
{
boxmsgdata('Please Input Email');
$('#registerform-'+resid+' input[name="email_signup"]').focus();
return false;


}
else
{

    datasend['email']=$('#registerform-'+resid+' input[name="email_signup"]').val();
    
    

}


if($('#registerform-'+resid+' input[name="password_signup"]').val()=="")
{
boxmsgdata('Please Input Password');
$('#registerform-'+resid+' input[name="password_signup"]').focus();
return false;


}


if($('#registerform-'+resid+' input[name="repassword_signup"]').val()=="")
{
boxmsgdata('Please Input RePassword');
$('#registerform-'+resid+' input[name="repassword_signup"]').focus();
return false;


}


if($('#registerform-'+resid+' input[name="recaptcha_response_field"]').val()=="")
{
boxmsgdata('Please Input Recaptcha');
$('#registerform-'+resid+' input[name="recaptcha_response_field"]').focus();
return false;


}else
{

datasend['recaptchac']=$('#registerform-'+resid+' input[name="recaptcha_challenge_field"]').val();  
datasend['recaptcha']=$('#registerform-'+resid+' input[name="recaptcha_response_field"]').val();    
    
    
}

if($('#registerform-'+resid+' input[name="repassword_signup"]').val()!=$('#registerform-'+resid+' input[name="password_signup"]').val())
{

boxmsgdata('Password does not match the confirm password');
$('#registerform-'+resid+' input[name="repassword_signup"]').focus();
return false;



}else
{

datasend['password']=$('#registerform-'+resid+' input[name="repassword_signup"]').val();

loaddata();
$.post(serviceinfo+"signup",datasend,
function(data){
loadclosedata();
if(data.error.response)
{
showRecaptcha('recaptcha_div-'+resid);
//console.log(data.error.error[0]);
boxmsgdata(data.error.error[0].msg);

}else
{

savereservedataregister(productid,resid);


}

});


}


}

var productidsetres=0;
function savereservedataregister(productid,resid)
{
productidsetres=productid;
var parem=new Array();
parem[0]=productid;
loaddata();
$.get(serviceinfo+'getmedthodplugin', { classset:'reservationregister',medthodset:'savereservedata',parem:parem }, function(data) { 
loadclosedata();
if(data.error.response)
{
var today = new Date();
var getfullyear= today.getFullYear();
var code = '<form id="formregisterdatarow-'+resid+'" >\n';
code += '<div class="wrpHdInfoGen mgBtm10 clBg2">\n';
code += '<h2 class="clTxt2 fs04 boldGen">ใบสมัครเข้าร่วมกิจกรรม</h2>\n';
code += '</div>\n';
code += '<div style="display:none" class="qstRgtFrm clTxt3 fs03 boldGen clearfix">\n';
code += '<span class="spnQstRgtFrm" >Do you have CanonLife account?</span>\n';
code += '<div class="inpQstRgtFrm">\n';
code += '<input checked="checked" type="radio" value="1" name="qstrgt">\n';
code += '<label class="fs03 clTxt3">Yes</label>\n';
code += '<input type="radio" value="2" name="qstrgt">\n';
code += '<label class="fs03 clTxt3">No</label>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div style="display:none" class="tbRgtFrm tbRgtFrmNom clBd2 bdFull clBg3">\n';
code += '<table class="tbGenInfo clTxt3 fs03">\n';
code += '<tbody><tr>\n';

code += '<th>Username</th>\n';
code += '<td>\n';
code += '<input type="text" name="username_signup" class="clBg5 clBd2 fs03 clTxt2">\n';
code += '</td>\n';
code += '</tr>\n';


code += '<tr>\n';
code += '<th>Email</th>\n';
code += '<td>\n';
code += '<input type="text" name="email_signup" class="clBg5 clBd2 fs03 clTxt2">\n';
code += '</td>\n';
code += '</tr>\n';

code += '<tr>\n';
code += '<th>Password</th>\n';
code += '<td>\n';
code += '<input type="password" name="password_signup" class="clBg5 clBd2 fs03 clTxt2">\n';
code += '</td>\n';
code += '</tr>\n';


code += '<tr>\n';
code += '<th>Confirm Password</th>\n';
code += '<td>\n';
code += '<input type="password" name="repassword_signup" class="clBg5 clBd2 fs03 clTxt2">\n';
code += '</td>\n';
code += '</tr>\n';


code += '<tr>\n';
code += '<th>Recapcha</th>\n';
code += '<td id="recaptcha_div-'+resid+'">\n';
code += '';
code += '</td>\n';
code += '</tr>\n';




code += '</tbody></table>\n';

code += '<div class="btnLIAtFl">\n';
code += '<input type="button" onclick="signupuserreservation('+productid+','+resid+')" class="btnGen clTxtW cutTxt clBgSp2 fs04" value="SignUp">\n';
code += '</div>\n';

code += '</div>\n';
code += '<div style="display:none" class="tbRgtFrm tbRgtFrmMem clBd2 bdFull clBg3">\n';
code += '<table class="tbGenInfo clTxt3 fs03">\n';
code += '<tbody><tr>\n';
code += '<th>Username or Email</th>\n';
code += '<td>\n';
code += '<input type="text" name="username_login" class="clBg5 clBd2 fs03 clTxt2">\n';
code += '</td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>Password</th>\n';
code += '<td>\n';
code += '<input type="password" name="password_login" class="clBg5 clBd2 fs03 clTxt2">\n';
code += '</td>\n';
code += '</tr>\n';
code += '</tbody></table>\n';
code += '<div class="btnLIAtFl">\n';
code += '<input type="button" onclick="loginuserreservation('+productid+','+resid+')" class="btnGen clTxtW cutTxt clBgSp2 fs04" value="Log In &amp; Using My Profile Data">\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpAllInfoRgtFrm">\n';
code +='<div class="wrnRgtFrm"><span class="fs07 clErrTxt">*** ถ้าช่องใดไม่มีข้อมูลกรุณาใส่เครื่องหมายขีด (-) ***</span></div>';

code += '<div class="wrpGenInfo mgBtm10">\n';
code += '<div class="wrpHdInfoGen mgBtm10">\n';
code += '<h2 class="ttlFullPf clTxt2 fs04 boldGen">ข้อมูลพื้นฐาน (กรุณากรอกจนครบ)</h2>\n';
code += '</div>\n';
code += '<table class="tbGenInfo clTxt2 fs03">\n';
code += '<tbody><tr>\n';
code += '<th>ชื่อเล่น</th>\n';
code += '<td><input type="hidden" name="nochecksameaddress" value="1"><input type="hidden" name="filter" value="1"><input name="displayname" type="text" class="clBg5 clBd2 fs03 clTxt2"></td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>ชื่อจริง</th>\n';
code += '<td><input name="firstname" type="text" class="clBg5 clBd2 fs03 clTxt2"></td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>นามสกุล</th>\n';
code += '<td><input name="lastname"  type="text" class="clBg5 clBd2 fs03 clTxt2"></td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>เพศ</th>\n';
code += '<td>\n';
code += '<div class="slctGen">\n';
code += '<input type="radio"  value="1" name="gender">\n';
code += '<label class="fs03 clTxt3" for="male">ชาย</label>\n';
code += '<input type="radio"  value="2" name="gender">\n';
code += '<label class="fs03 clTxt3" for="female">หญิง</label>\n';
code += '<input type="radio"  value="0" name="gender">\n';
code += '<label class="fs03 clTxt3" for="other">ไม่ระบุ</label>\n';
code += '</div>\n';
code += '</td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th> วัน เดือน ปี เกิด   </th>\n';
code +='<td >\n';


code +='<input name="dayBirthtext" readonly="readonly"  type="text" class="clBg5 clBd2 fs03 clTxt2">';

//code += '<div class="reDesign reDsDayBirth">\n';
//
//code += '<select class="dayBirth" name="daybirth">\n';
//code += '<option selected="selected"  value="00">เลือกวัน</option>';
//code += '<option value="01">1</option>\n';
//code += '<option value="02">2</option>\n';
//code += '<option value="03">3</option>\n';
//code += '<option value="04">4</option>\n';
//code += '<option value="05">5</option>\n';
//code += '<option value="06">6</option>\n';
//code += '<option value="07">7</option>\n';
//code += '<option value="08">8</option>\n';
//code += '<option value="09">9</option>\n';
//code += '<option value="10">10</option>\n';
//code += '<option value="11">11</option>\n';
//code += '<option value="12">12</option>\n';
//code += '<option value="13">13</option>\n';
//code += '<option value="14">14</option>\n';
//code += '<option value="15">15</option>\n';
//code += '<option value="16">16</option>\n';
//code += '<option value="17">17</option>\n';
//code += '<option value="18">18</option>\n';
//code += '<option value="19">19</option>\n';
//code += '<option value="20">20</option>\n';
//code += '<option value="21">21</option>\n';
//code += '<option value="22">22</option>\n';
//code += '<option value="23">23</option>\n';
//code += '<option value="24">24</option>\n';
//code += '<option value="25">25</option>\n';
//code += '<option value="26">26</option>\n';
//code += '<option value="27">27</option>\n';
//code += '<option value="28">28</option>\n';
//code += '<option value="29">29</option>\n';
//code += '<option value="30">30</option>\n';
//code += '<option value="31">31</option>\n';
//code += '</select>\n';

//code += '</div>\n';

//code += '<div class="reDesign reDsMonthBirth">\n';

//code += '<select name="monthbirth" class="monthBirth">\n';
//code += '<option selected="selected" value="00">เลือกเดือน</option>';
//code += '<option value="01">January</option>\n';
//code += '<option value="02">Febuary</option>\n';
//code += '<option value="03">March</option>\n';
//code += '<option value="04">April</option>\n';
//code += '<option value="05">May</option>\n';
//code += '<option value="06">June</option>\n';
//code += '<option value="07">July</option>\n';
//code += '<option value="08">August</option>\n';
//code += '<option value="09">September</option>\n';
//code += '<option value="10">October</option>\n';
//code += '<option value="11">November</option>\n';
//code += '<option value="12">December</option>\n';
//code += '</select>\n';


//code += '</div>\n';

//code += '<div class="reDesign reDsYearBirth">\n';
//code += '<select name="yearbirth" class="yearBirth">\n';
//code += '<option selected="selected" value="0000">เลือกปี</option>';



//code += '</select>\n';
//code += '</div>\n';

code += '</td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>ประโยคประจำใจ (ถ้าไม่มี กรุณาใส่เครื่องหมาย -)</th>\n';
code += '<td><textarea name="description" class="clBg5 clBd2 fs03 clTxt2"></textarea></td>\n';
code += '</tr>\n';
code += '</tbody></table>\n';
code += '</div>\n';
code += '<div class="wrpAdrsInfo mgBtm10">\n';
code += '<div class="wrpHdInfoGen mgBtm10">\n';
code += '<h2 class="ttlFullPf clTxt2 fs04 boldGen">ข้อมูลที่อยู่ปัจจุบัน (กรุณากรอกจนครบ)</h2>\n';
code += '</div>\n';
code += '<table class="tbGenInfo clTxt3 fs03">\n';
code += '<tbody><tr>\n';
code += '<th>ที่อยู่</th>\n';
code += '<td><textarea  name="address"  class="clBg5 clBd2 fs03 clTxt2"></textarea></td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>ประเทศ</th>\n';
code += '<td>\n';
code += '<div class="reDesign">\n';
code += '<select name="countryid" id="countryid-1" class="fs01">\n';
code += '<option  value="0">เลือกประเทศ</option>';
code += '</select>\n';
code += '</div>\n';
code += '</td>\n';
code += '</tr>\n';

code += '<tr class="prothaiclass">\n';
code += '<th>จังหวัด</th>\n';
code += '<td>\n';
code += '<div class="reDesign ">\n';
code += '<select name="proid" id="proid-1" class="fs01">\n';
code += '<option  value="0">เลือกจังหวัด</option>';
code += '</select>\n';
code += '</div>\n';
code += '</td>\n';
code += '</tr>\n';

code += '<tr class="prothaiclass">\n';
code += '<th>อำเภอ / เขต</th>\n';
code += '<td>\n';
code += '<div class="reDesign">\n';
code += '<select name="disid" id="disid-1" class="fs01">\n';
code += '<option  value="0">เลือก อำเภอ/เขต</option>';
code += '</select>\n';
code += '</div>\n';
code += '</td>\n';
code += '</tr>\n';


code += '<tr class="prothaiclass">\n';
code += '<th> ตำบล / แขวง</th>\n';
code += '<td>\n';
code += '<div  class="reDesign">\n';
code += '<select name="tumid" id="tumid-1" class="fs01">\n';
code += '<option  value="0">เลือก  ตำบล / แขวง</option>\n';
code += '</select>\n';
code += '</div>\n';
code += '</td>\n';
code += '</tr>\n';


code += '<tr class="prootherclass" style="display:none">\n';
code += '<th>State</th>\n';
code += '<td>\n';
code += '<input name="state" type="text" class="inpPostCode clBg5 clBd2 fs03 clTxt2">\n';
code += '</td>\n';
code += '</tr>\n';



code += '<tr>\n';
code += '<th>รหัสไปรษณีย์</th>\n';
code += '<td>\n';
code += '<input name="code" type="text" class="inpPostCode clBg5 clBd2 fs03 clTxt2">\n';
code += '</td>\n';
code += '</tr>\n';
code += '</tbody></table>\n';
code += '</div>\n';
code += '<div class="wrpCtcInfo">\n';
code += '<div class="wrpHdInfoGen mgBtm10">\n';
code += '<h2 class="ttlFullPf clTxt2 fs04 boldGen">ข้อมูลที่ใช้ติดต่อ (ถ้าไม่มี กรุณาใส่เครื่องหมาย -)</h2>\n';
code += '</div>\n';
code += '<table class="tbGenInfo clTxt3 fs03">\n';
code += '<tbody>\n';
code += '<tr>\n';
code += '<th>อีเมล์</th>\n';
code += '<td><input name="email" type="text" class="clBg5 clBd2 fs03 clTxt2"></td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>เบอร์โทรศัพท์</th>\n';
code += '<td><input name="phone" type="text" class="clBg5 clBd2 fs03 clTxt2"></td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>แฟกซ์</th>\n';
code += '<td><input name="fax" type="text" class="clBg5 clBd2 fs03 clTxt2"></td>\n';
code += '</tr>\n';

code += '<tr><th>Facebook</th>\n';
code += '<td><input name="facebook" type="text" placeholder="e.g. facebook.com/dmconnex" class="clBg5 clBd2 fs03 clTxt2"></td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>Twitter</th>\n';
code += '<td><input name="twitter" type="text" placeholder="e.g. twitter.com/dmconnex" class="clBg5 clBd2 fs03 clTxt2"></td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>Google Plus</th>\n';
code += '<td><input name="googleplus" type="text" placeholder="e.g. plus.google.com/+dmconnex" class="clBg5 clBd2 fs03 clTxt2"></td>\n';
code += '</tr>\n';
code += '<tr>\n';
code += '<th>เว็บไซต์ส่วนตัว</th>\n';
code += '<td><input name="website" type="text" class="clBg5 clBd2 fs03 clTxt2"></td>\n';
code += '</tr>\n';



code += '<tr>\n';
code += '<th>อื่นๆ</th>\n';
code += '<td><textarea name="etc" class="clBg5 clBd2 fs03 clTxt2"></textarea></td>\n';
code += '</tr>\n';
code += '</tbody></table>\n';
code += '</div>\n';
code += '<div class="wrpPdCnInfo">\n';
code += '<div class="wrpHdInfoGen mgBtm10">\n';
code += '<h2 class="ttlFullPf clTxt2 fs04 boldGen">ข้อมูลสินค้าที่ถืออยู่ (ถ้ามี)</h2>\n';
code += '</div>\n';
code += '<table class="tbGenInfo clTxt3 fs03" id="maintablecanonproduct-'+resid+'">\n';
code += '<tbody id="tablecanonproduct-'+resid+'">\n';

code += '<tr><th class="spnHdQstRgtFrm">กรุณากรอกเฉพาะสินค้า Canon ประกันศูนย์ เท่านั้น</th>\n';
code += '<td class="moreQstRgtFrm">\n';
code += '<input type="button" onclick="moredataproduct('+resid+')" value="Add More" class="btnGen clTxtW cutTxt clBgBt1 fs04">\n';
code += '</td>\n';
code += '</tr>\n';

code += '<tr>\n';
code += '<th>รหัสสินค้า</th>\n';
code += '<td class="tbInpRmvRgtCn clearfix">\n';
code += '<input name="serialnumber[]" type="text" class="clBg5 clBd2 fs03 clTxt2">\n';
//code += '<div class="rmvPdCn clBgBt1">\n';
//code += '<span class="ico icoRmvPd"></span>\n';
//code += '</div>\n';
code += '</td>\n';
code += '</tr>\n';

code += '<tr>\n';
code += '<th>โมเดลสินค้า</th>\n';
code += '<td><input name="modelnumber[]" type="text" class="clBg5 clBd2 fs03 clTxt2"></td>\n';
code += '</tr>\n';

code += '</tbody></table>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="btnSmRgtCn">\n';
code += '<input type="button" onclick="saveformregistering('+resid+','+productid+')" value="Submit" class="btnGen clTxtW cutTxt clBgSp2 fs04">\n';
code += '</div>\n';
code += '';

if(data.error.error[0].code==27)
{





$('#registerform-'+resid).html(code);


$('#registerform-'+resid+' input[name="displayname"]').val(data.data.displayname);
$('#registerform-'+resid+' input[name="firstname"]').val(data.data.firstname);
$('#registerform-'+resid+' input[name="lastname"]').val(data.data.lastname);



$('#registerform-'+resid+' input:radio[name="gender"]').filter('[value="'+data.data.gender+'"]').attr('checked', true);




var res = data.data.birthdate.split('-'); 

if(res[2]!="00"&&res[1]!="00"&&res[0]!="0000")
{
$('#registerform-'+resid+' input[name="dayBirthtext"]').val(res[2]+'/'+res[1]+'/'+res[0]);
}

$('#registerform-'+resid+' input[name="dayBirthtext"]').datepicker({
changeMonth: true,
changeYear: true,
yearRange: "-100:+0",
dateFormat:'dd/mm/yy'
});


//$('#registerform-'+resid+' select[name="daybirth"]').val(res[2]);
//$('#registerform-'+resid+' select[name="monthbirth"]').val(res[1]);
//$('#registerform-'+resid+' select[name="yearbirth"]').val(res[0]);

$('#registerform-'+resid+' textarea[name="description"]').val(data.data.description);
$('#registerform-'+resid+' textarea[name="address"]').val(data.data.address);




getcountry('#registerform-'+resid+' select[name="countryid"]',data.data.countryid);

var jqxhr= getprovince('#registerform-'+resid+' select[name="proid"]',data.data.proid);

  jqxhr.done(function() {
     
     if(data.data.proid!="0")
     {
     var jqxhr2=getdistrict('#registerform-'+resid+' select[name="disid"]','#registerform-'+resid+' select[name="tumid"]',data.data.proid,data.data.disid);
     
      jqxhr2.done(function() {
      
           if(data.data.disid!="0")
           {
     
                       gettumbon('#registerform-'+resid+' select[name="tumid"]',data.data.disid,data.data.tumid);
     
             }
      
      
      
      });
     
     
     
     }
     
      
  });
   
   
   
   
   if(data.data.countryid=="210")
  {
     $('#registerform-'+resid+" .prothaiclass").show();
     $('#registerform-'+resid+" .prootherclass").hide();

  
  
  }else
  {
      $('#registerform-'+resid+" .prothaiclass").hide();
      $('#registerform-'+resid+" .prootherclass").show();
      
      
      $('#registerform-'+resid+' input[name="state"]').val(data.data.state);

  
  }
   
   
 $('#registerform-'+resid+' select[name="countryid"]').change(function() 
    { 
     
         if($(this).val()==210)
  {
     $('#registerform-'+resid+" .prothaiclass").show();
     $('#registerform-'+resid+" .prootherclass").hide();

  
  
  }else
  {
      $('#registerform-'+resid+" .prothaiclass").hide();
      $('#registerform-'+resid+" .prootherclass").show();

  
  }
    
    });
    
    
 $('#registerform-'+resid+' select[name="proid"]').change(function() 
    { 
    
      // getdistrict("#feature"+rownow+' select[name="disid[]"]',"#feature"+rownow+' select[name="tumid[]"]',$(this).val());
       
       getdistrict('#registerform-'+resid+' select[name="disid"]','#registerform-'+resid+' select[name="tumid"]',$(this).val()); 
    
    });
    
 $('#registerform-'+resid+' select[name="disid"]').change(function() 
    {
    gettumbon('#registerform-'+resid+' select[name="tumid"]',$(this).val());
    
    });
    
    
 $('#registerform-'+resid+' input[name="code"]').val(data.data.code);
 $('#registerform-'+resid+' input[name="facebook"]').val(data.data.facebook);
 $('#registerform-'+resid+' input[name="twitter"]').val(data.data.twitter);
 $('#registerform-'+resid+' input[name="googleplus"]').val(data.data.googleplus);
 $('#registerform-'+resid+' input[name="website"]').val(data.data.website);
 $('#registerform-'+resid+' input[name="email"]').val(data.data.email);
 $('#registerform-'+resid+' input[name="phone"]').val(data.data.phone);
 $('#registerform-'+resid+' input[name="fax"]').val(data.data.fax);
 $('#registerform-'+resid+' textarea[name="etc"]').val(data.data.etc);
    
    
 
if(data.data.roleid=="1")
{


//$('#maintablecanonproduct-'+resid).fadeIn();

}



$('#reserveform-'+resid).fadeOut();
$('#reserveform-'+resid+' .btnSmRgtCn').show();

$('#registerform-'+resid).fadeIn();


var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
if(isAndroid) {

}
else
{

$("#main-middle .wrpUinLd").mCustomScrollbar("update");
//$("#main-middle .wrpUinLd").mCustomScrollbar("destroy");

//setTimeout('rowscrolllanding();',1000);
}




//$('.wrprMiniPop.wrpPopMiniTel').fadeIn();

}else
{


if(data.error.error[0].code==5)
{
$('#registerform-'+resid).html(code);

$('#registerform-'+resid+' .wrpAllInfoRgtFrm').hide();
//$('#registerform-'+resid+' .tbRgtFrm.tbRgtFrmNom').fadeIn();


$('#registerform-'+resid+' .qstRgtFrm').show();
$('#registerform-'+resid+' .tbRgtFrm.tbRgtFrmMem').show();

$('#reserveform-'+resid).fadeOut();
$('#registerform-'+resid+' .btnSmRgtCn').hide();
$('#registerform-'+resid).fadeIn();




$('#registerform-'+resid+' input[name="qstrgt"]').change(function() {

if($(this).val()=="1")
{
$('#registerform-'+resid+' .tbRgtFrm.tbRgtFrmMem').fadeIn();
$('#registerform-'+resid+' .tbRgtFrm.tbRgtFrmNom').fadeOut();

}else
{
$('#registerform-'+resid+' .tbRgtFrm.tbRgtFrmMem').fadeOut();
$('#registerform-'+resid+' .tbRgtFrm.tbRgtFrmNom').fadeIn();

showRecaptcha('recaptcha_div-'+resid);

}


});



var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
if(isAndroid) {

}
else
{
$("#main-middle .wrpUinLd").mCustomScrollbar("update");
}
//$('.ovlPopLd').hide();
//$('.wrpPopSU').fadeIn();

}else
{
boxmsgdata(data.error.error[0].msg);

}

}


}else
{
var code2 ='<div class="rsvThankJoin"><span class="clTxt1 fs11">Thank You For Joining Us</span></div>';

code2 +='<div class="cpltRsv fs04 clTxt2"><span>To complete reservation, you must confirmation via your email address.</span><span>If you do not receiving email from us, please check your Junk Email folder</span><span>or <a href="javascript:savereservedataregister('+productid+','+resid+')">click here to re-send email.</a></span></div>';

$('.registerbtndiv').html(code2);
boxmsgdata('Success');

}

});


}

function saveformregistering(resid,productid)
{
if($('#formregisterdatarow-'+resid+' input[name="displayname"]').val()=="")
{

     boxmsgdata('Please Input Displayname');
     $('#formregisterdatarow-'+resid+' input[name="displayname"]').focus();
  

}else if($('#formregisterdatarow-'+resid+' input[name="firstname"]').val()=="")
{
    boxmsgdata('Please Input Firstname');
    $('#formregisterdatarow-'+resid+' input[name="firstname"]').focus();

}else if($('#formregisterdatarow-'+resid+' input[name="lastname"]').val()=="")
{
    boxmsgdata('Please Input Lastname');
    $('#formregisterdatarow-'+resid+' input[name="lastname"]').focus();

}else if($('#formregisterdatarow-'+resid+' input[name="gender"]:checked').val()=="0")
{
    boxmsgdata('Please Choose Gender');
  

}else if($('#formregisterdatarow-'+resid+' input[name="dayBirthtext"]').val()=="")
{
    boxmsgdata('Please Input Date of Birth');
    $('#formregisterdatarow-'+resid+' input[name="dayBirthtext"]').focus();
  

}else if($('#formregisterdatarow-'+resid+' textarea[name="description"]').val()=="")
{
    boxmsgdata('Please Input Description');
  

}else if($('#formregisterdatarow-'+resid+' textarea[name="address"]').val()=="")
{
    boxmsgdata('Please Input Address');
  

}else if($('#formregisterdatarow-'+resid+' select[name="countryid"]').val()=="0")
{
    boxmsgdata('Please Choose Country');
  

}else if($('#formregisterdatarow-'+resid+' select[name="countryid"]').val()=="210"&&($('#formregisterdatarow-'+resid+' select[name="proid"]').val()=="0"))
{
     boxmsgdata('Please Choose Province');

}else if($('#formregisterdatarow-'+resid+' select[name="countryid"]').val()=="210"&&($('#formregisterdatarow-'+resid+' select[name="disid"]').val()=="0"))
{
    boxmsgdata('Please Choose District');

}else if($('#formregisterdatarow-'+resid+' select[name="countryid"]').val()=="210"&&($('#formregisterdatarow-'+resid+' select[name="tumid"]').val()=="0"))
{
    boxmsgdata('Please Choose Tumbon');

}else if($('#formregisterdatarow-'+resid+' select[name="countryid"]').val()!="210"&&($('#formregisterdatarow-'+resid+' input[name="state"]').val()==""))
{
    boxmsgdata('Please Choose State');
        $('#formregisterdatarow-'+resid+' input[name="state"]').focus();

}
else if($('#formregisterdatarow-'+resid+' input[name="code"]').val()=="")
{
    boxmsgdata('Please Input Postal Code');
    $('#formregisterdatarow-'+resid+' input[name="code"]').focus();

}else if($('#formregisterdatarow-'+resid+' input[name="facebook"]').val()=="")
{
    boxmsgdata('Please Input Facebook');
    $('#formregisterdatarow-'+resid+' input[name="facebook"]').focus();

}else if($('#formregisterdatarow-'+resid+' input[name="twitter"]').val()=="")
{
    boxmsgdata('Please Input Twitter');
    $('#formregisterdatarow-'+resid+' input[name="twitter"]').focus();

}else if($('#formregisterdatarow-'+resid+' input[name="googleplus"]').val()=="")
{
    boxmsgdata('Please Input Googleplus');
    $('#formregisterdatarow-'+resid+' input[name="googleplus"]').focus();

}else if($('#formregisterdatarow-'+resid+' input[name="website"]').val()=="")
{
    boxmsgdata('Please Input Website');
    $('#formregisterdatarow-'+resid+' input[name="website"]').focus();

}else if($('#formregisterdatarow-'+resid+' input[name="email"]').val()=="")
{
    boxmsgdata('Please Input Email');
    $('#formregisterdatarow-'+resid+' input[name="email"]').focus();

}else if($('#formregisterdatarow-'+resid+' input[name="phone"]').val()=="")
{
    boxmsgdata('Please Input Phone');
    $('#formregisterdatarow-'+resid+' input[name="phone"]').focus();

}else if($('#formregisterdatarow-'+resid+' input[name="fax"]').val()=="")
{
    boxmsgdata('Please Input Fax');
    $('#formregisterdatarow-'+resid+' input[name="fax"]').focus();

}else if($('#formregisterdatarow-'+resid+' textarea[name="etc"]').val()=="")
{
    boxmsgdata('Please Input Etc');
    $('#formregisterdatarow-'+resid+' textarea[name="etc"]').focus();

}else
{


loaddata();
$.post(serviceinfo+'savesetting',$('#formregisterdatarow-'+resid).serialize() , function(data) { 

loadclosedata();
if(data.error.response)
{

boxmsgdata(data.error.error[0].msg);

//alertboxtext(data.error.error,$("#validateerror-login"));

}else
{
boxmsgdata('Success');

$('#reserveform-'+resid).fadeIn();
$('#reserveform-'+resid+' .btnSmRgtCn').show();

$('#registerform-'+resid).fadeOut();

savereservedataregister(productid,resid);
//$('#txtbroadcast2').val('');
//location.href=baseinfo;


}


});


}





}

var rowdataproductitem=1;
function moredataproduct(resid)
{
var code = '<tr class="dataproductitem-'+rowdataproductitem+'">\n';
code += '<th class="spnHdQstRgtFrm">Other product</th>\n';
code += '<td class="moreQstRgtFrm">\n';
//code += '<input type="button" value="Add More" class="btnGen clTxtW cutTxt clBgBt1 fs04">\n';
code += '</td>\n';
code += '</tr>';

code += '<tr class="dataproductitem-'+rowdataproductitem+'">\n';
code += '<th>Serial Number</th>\n';
code += '<td class="tbInpRmvRgtCn clearfix">\n';
code += '<input name="serialnumber[]" type="text" class="clBg5 clBd2 fs03 clTxt2">\n';
code += '<div class="rmvPdCn clBgBt1" onclick="removerowitemproduct('+rowdataproductitem+')">\n';
code += '<span class="ico icoRmvPd"></span>\n';
code += '</div>\n';
code += '</td>\n';
code += '</tr>\n';

code += '<tr class="dataproductitem-'+rowdataproductitem+'" >\n';
code += '<th>Product Model</th>\n';
code += '<td><input name="modelnumber[]" type="text" class="clBg5 clBd2 fs03 clTxt2"></td>\n';
code += '</tr>\n';

$('#tablecanonproduct-'+resid).append(code);
rowdataproductitem++;

}
function removerowitemproduct(rowdataproductitemset)
{
$('.dataproductitem-'+rowdataproductitemset).remove();

}

function saveformreservationregister(id,plugid)
{
    var obj={};
    var unseat=0;
    if($("#"+id+' input[name="unseat[]"]').is(':checked'))
    {
         unseat=1;
    
    }
    
    
    var unreser=0;
    if($("#"+id+' input[name="unreser[]"]').is(':checked'))
    {
         unreser=1;
    
    }
    
    
    obj={plugid:plugid,
    seat:$("#"+id+' input[name="seat[]"]').val(),
    unseat:unseat,
    unreser:unreser,
    premium:$("#"+id+' input[name="premium[]"]:checked').val(),
    showlist:$("#"+id+' input[name="showlist[]"]:checked').val(),
    reserve:$("#"+id+' input[name="reserve[]"]').val()
    
    
    
    };
    return obj;

}
function editformreservationregister(datarow)  
{
    addformreservationregister();
    var rownow= rowdiv-1;
    $('#feature'+rownow+' input[name="seat[]"]').val(datarow.seat);
    $('#feature'+rownow+' input[name="reserve[]"]').val(datarow.reserve);
    
    if(datarow.unseat!="0")
    {
        $('#feature'+rownow+' input[name="unseat[]"]').attr('checked', 'checked');
    }
    
    if(datarow.unreser!="0")
    {
        $('#feature'+rownow+' input[name="unreser[]"]').attr('checked', 'checked');
    }

    //$('#feature'+rownow+' input[name="unreser[]"]').val(datarow.reserve);
    if(datarow.premium=='1')
    {
    $('#feature'+rownow+' .checkdata2').attr('checked', 'checked');
    }else
    {
    $('#feature'+rownow+' .checkdata1').attr('checked', 'checked');
    
    }
    
        if(datarow.showlist=='1')
    {
    $('#feature'+rownow+' .checkdata3').attr('checked', 'checked');
    }else
    {
    $('#feature'+rownow+' .checkdata4').attr('checked', 'checked');
    
    }
    

}
var checkmypost=0;
var showlist=0;
function getpageuserlist(div,pageallset,rowpage,productid,status)
{

if(pageallset!=0)
{
setpaginationnoreverse(div,pageallset,rowpage,'getrowuserlist',productid,status,0);
}


}
function searchreservationdata(productid,status)
{
var div='#main-middle .searchwaiting';
var div2='#main-middle .pagewaiting';
var div3='#main-middle .lstWait';
if(status==2)
{
div='#main-middle .searchconfirm';
div2='#main-middle .pagecomfirm';
div3='#main-middle .lstCfm';
}
searchstr=$(div).val();
var parem=new Array();
parem[0]=productid;
parem[1]=status;
loaddata();
$(div2).html('');
$(div3).html('');
$.post(serviceinfo+'postmedthodplugin', { classset:'reservationregister',medthodset:'countuserlistreservation',parem:parem,search:searchstr }, function(arraydata) { 

loadclosedata();
var countall=parseInt(arraydata.data.countdata,10);
getpageuserlist(div2,countall,10,productid,status);
getrowuserlist(1,productid,status,0)

});

}
var searchstr='';
function getrowuserlist(pagedata,productid,status,etc)
{
var parem=new Array();
parem[0]=productid;
parem[1]=status;
loaddata();
$.post(serviceinfo+'postmedthodplugin', { classset:'reservationregister',medthodset:'getuserlistreservation',parem:parem,page:pagedata,search:searchstr }, function(arraydata) { 

loadclosedata();

var code1='';
if(arraydata['data'].length)
{


$.each(arraydata['data'], function(key, valueuserlist) {


if((checkmypost||roleidinfo==3)||(valueuserlist['userid']==useridinfo)||showlist==1)
{

code1 += '<li class="clearfix" id="liuser-'+valueuserlist['resvid']+'">'+"\n";
code1 += '<div class="rgtName">'+"\n";

var check='';
if(valueuserlist['status']==2)
{
var check=' checked="checked" ';
}
if(checkmypost||roleidinfo==3)
{
code1 += '<input id="checkuser-'+valueuserlist['resvid']+'" type="checkbox" '+check+' onclick="checkuserconfirmregister('+valueuserlist['resvid']+','+arraydata['productid']+')">'+"\n";
}


code1 += '<a href="'+baseinfo+'/'+valueuserlist['username']+'" target="_blank"><img width="24" height="24" alt="img" src="'+valueuserlist['userssimg']['newpath']+'" class="genImgUser">'+"\n";
code1 += '<span class="cutTxt">'+valueuserlist['displayname']+'</span></a>'+"\n";
code1 += '</div>'+"\n";
if(checkmypost||roleidinfo==3)
{
code1 += '<span class="rgtInfo rgsDelRsv" onclick="deleteuserconfirmregister('+valueuserlist['resvid']+','+arraydata['productid']+')" >'+"\n";
code1 += '<em class="ico icoDelRsv"></em>'+"\n";
code1 += '</span>'+"\n";
code1 += '<span class="rgtInfo rgtInfoRsv" onclick="openaddreservationregister(\''+valueuserlist['displayname']+'\',\''+valueuserlist['email']+'\',\''+valueuserlist['phone']+'\')">'+"\n";
code1 += '<em class="ico icoInfoRsv"></em>'+"\n";
code1 += '</span>'+"\n";
}
code1 += '</li>'+"\n";

}










} );

if(status==1)
{
$('#main-middle .lstWait').html(code1);
}else
{
$('#main-middle .lstCfm').html(code1);
}

}



});


}
